package com.example.blog_system_ssm.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;

@RestControllerAdvice
public class MyExceptionAdvice {
        @ExceptionHandler(Exception.class)
        public HashMap<String, Object> exceptionAdvice(Exception e){
            HashMap<String,Object> result=new HashMap<>();
            result.put("status",-1);
            result.put("message","代码出现异常,异常信息为："+e.getMessage());
            result.put("data",null);
            return result;
        }
}




